package org.ee.system.domain;

import jakarta.persistence.*;
import org.ee.framework.jpa.base.AbstractEntity;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import java.util.HashSet;
import java.util.Set;

/**
 * 系统用户数据对象
 */
@Entity
@Table(name = "sys_user")
@DynamicUpdate
@Cacheable
@DynamicInsert
@Comment("系统用户表")
public class UserInfo extends AbstractEntity<Long> {

    @Id
    @Comment("主键Id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Comment("用户名")
    private String userName;

    @Comment("密码")
    private String userPwd;

    @Comment("昵称")
    private String nickName;

    @Comment("姓名")
    private String realName;

    @Comment("性别")
    private Integer gender;

    @Comment("电子邮件")
    private String email;

    @Comment("联系电话")
    private String phone;

    @Comment("用户状态")
    private Integer status;

    @Comment("个人标签")
    private String selfLabel;

    @Comment("个人介绍")
    private String selfInfo;

    @Comment("排序字段")
    private Integer sortNum;

    @Comment("备注")
    private String remark;

    @Comment("头像")
    private String avatar;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "org_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
    private Organization organization;

    //关联映射
    @OneToMany(mappedBy = "user")
    private Set<UserRole> userRoles = new HashSet<>(0);

    @Override
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getUserPwd() {
        return userPwd;
    }

    public void setUserPwd(String userPwd) {
        this.userPwd = userPwd;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getRealName() {
        return realName;
    }

    public void setRealName(String realName) {
        this.realName = realName;
    }

    public Integer getGender() {
        return gender;
    }

    public void setGender(Integer gender) {
        this.gender = gender;
    }

    public String getSelfLabel() {
        return selfLabel;
    }

    public void setSelfLabel(String selfLabel) {
        this.selfLabel = selfLabel;
    }

    public String getSelfInfo() {
        return selfInfo;
    }

    public void setSelfInfo(String selfInfo) {
        this.selfInfo = selfInfo;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }


    public Integer getSortNum() {
        return sortNum;
    }

    public void setSortNum(Integer sortNum) {
        this.sortNum = sortNum;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public Set<UserRole> getUserRoles() {
        return userRoles;
    }

    public void setUserRoles(Set<UserRole> userRoles) {
        this.userRoles = userRoles;
    }

    public Organization getOrganization() {
        return organization;
    }

    public void setOrganization(Organization organization) {
        this.organization = organization;
    }

    @Override
    public String toString() {
        return "UserInfo{" +
                "id=" + id +
                ", userName='" + userName + '\'' +
                ", userPwd='" + userPwd + '\'' +
                ", nickName='" + nickName + '\'' +
                ", realName='" + realName + '\'' +
                ", gender=" + gender +
                ", email='" + email + '\'' +
                ", phone='" + phone + '\'' +
                ", status=" + status +
                ", selfLabel='" + selfLabel + '\'' +
                ", selfInfo='" + selfInfo + '\'' +
                ", sortNum=" + sortNum +
                ", remark='" + remark + '\'' +
                ", avatar='" + avatar + '\'' +
                ", organization=" + organization +
                ", userRoles=" + userRoles +
                '}';
    }
}
